package com.ews.onlineexchange.model;

import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.inject.Inject;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinTable;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.PostLoad;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Past;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

import org.apache.commons.lang3.StringUtils;
import org.apache.lucene.analysis.cn.smart.SmartChineseAnalyzer;
import org.hibernate.search.annotations.Analyze;
import org.hibernate.search.annotations.Analyzer;
import org.hibernate.search.annotations.Boost;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.validator.constraints.Length;

import com.ews.onlineexchange.model.assess.CreditLevel;
import com.ews.onlineexchange.service.DeterminedRecordService;
import com.ews.onlineexchange.service.RandomChooseService;
import com.ews.onlineexchange.util.SystemUUIDUtil;

/**
 * 实体名称：中介，竞标项目的用户 说明： 特点： 有资质清单 要经过线上两步审核。资质由所属行业管理部门审核。
 * 
 * @author 司冰
 *
 */
@Entity
@Indexed
@Boost(2.0F)
@Analyzer(impl = SmartChineseAnalyzer.class)
public class ServiceSupplier extends User {
	/**
	 * 
	 */
	private static final long		serialVersionUID	= 1L;

	private String					companyType;							// 单位性质或组织形式
	private String					creditCode;								// 组织机构代码/统一信用代码
	private BigDecimal				registeredFund;							// 注册资金
	private String					registrationAuthority;					// 注册机关
	private String					registrationNo;							// 注册登记号
	private Date					regtime;								// 成立时间
	private List<Image>				businessLicenseImages = new ArrayList<>();// 营业执照
	private List<Image>				taxProveImages = new ArrayList<>();		// 纳税证明
	private String					address;								// 办公地址
	private String					legalPerson;							// 法定代表人
	private String					legalPersonPhoneNumber;					// 法人电话号码
	private String					firstContactor;							// 第一联系人
	private String					firstContactorPhoneNumber;				// 第一联系人电话
	private String					secondContactor;						// 第二联写人
	private String					secondContactorPhoneNumber;				// 第二联写人电话
	private Integer					employeeCount;							// 员工数
	private Integer					highTitleEmployeeCount;					// 高级职称人数
	private Integer					mediumTitleEmployeeCount;				// 中级职称人数
	private Integer					beginnerTitleEmployeeCount;				// 初级职称人数
	private boolean					govServiceSupplier;						// 是否政府服务供应商
	//private String					region;									// 中介机构所在地区
	private boolean					alwaysValid;							// 是否长期有效
	private Date					busnissAllotedTime;						// 营业期限
	private String					branchesInfo;							// 分支机构登记情况
	private String					intro;									// 机构简介
	private List<Business>			businesses			= new ArrayList<>();// 主营业务 Deprecated
	private List<MainBusiness>		mainBusinesses 		= new ArrayList<>();// 主营业务
	private List<QualificationCert>	certs				= new ArrayList<>();// 证书
	private List<Attachment>		attachments			= new ArrayList<>();// 相关附件

	private BigDecimal				score = new BigDecimal(60);  //暂时没啥作用，get方法中获取的creditSocre的值
	private int						orderCount;						//评价次数
	
	private boolean					valid;
	private User                    auditUser;								 //审核用户
	private Date                    auditDate;
	/*
	 * 2019-11-09
	 * 司冰
	 * 增加新评价分值字段
	 */
	private BigDecimal				creditScore = new BigDecimal(60);
	
	/**
	 * 下面新增了一些临时字段，统计时用于存储统计内容
	 */

	
	@NotNull
	public String getCompanyType() {		
		return companyType;
	}

	public void setCompanyType(String companyType) {
		this.companyType = companyType;
	}

	@NotNull
	@Column(unique = true)
	// TODO 编码规则验证
	public String getCreditCode() {
		return creditCode;
	}

	public void setCreditCode(String creditCode) {
		this.creditCode = StringUtils.trim(creditCode);
	}

	@NotNull
	@Min(1L)
	@Column(precision =20, scale = 4)
	public BigDecimal getRegisteredFund() {
		return registeredFund;
	}

	public void setRegisteredFund(BigDecimal registeredFund) {
		this.registeredFund = registeredFund;
	}

	@NotNull
	public String getRegistrationAuthority() {
		return registrationAuthority;
	}

	public void setRegistrationAuthority(String registrationAuthority) {
		this.registrationAuthority = registrationAuthority;
	}

	public String getRegistrationNo() {
		return registrationNo;
	}

	public void setRegistrationNo(String registrationNo) {
		this.registrationNo = registrationNo;
	}

	@NotNull
	@Temporal(TemporalType.DATE)
	@Past
	public Date getRegtime() {
		return regtime;
	}

	public void setRegtime(Date regtime) {
		this.regtime = regtime;
	}

	
	@Temporal(TemporalType.TIMESTAMP)
	public Date getAuditDate() {
		return auditDate;
	}

	public void setAuditDate(Date auditDate) {
		this.auditDate = auditDate;
	}

	@NotNull
	@Field
	@Boost(0.8F)
	@Field(analyzer = @Analyzer(impl = SmartChineseAnalyzer.class))
	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	@NotNull
	@Field
	@Boost(1.0F)
	public String getLegalPerson() {
		return legalPerson;
	}

	public void setLegalPerson(String legalPerson) {
		this.legalPerson = legalPerson;
	}

	@NotNull
	@Pattern(regexp = "(1\\d{10}|(\\d{3,4}-)?\\d{7,8}(-\\d{1,4})?){1}", message = "请输入正确格式的电话号码：手机号或【3-4位区号】-【7-8位电话号码】-【1-4位】分机号")
	public String getLegalPersonPhoneNumber() {
		return legalPersonPhoneNumber;
	}

	public void setLegalPersonPhoneNumber(String legalPersonPhoneNumber) {
		this.legalPersonPhoneNumber = legalPersonPhoneNumber;
	}

	@NotNull
	public String getFirstContactor() {
		return firstContactor;
	}

	public void setFirstContactor(String firstContactor) {
		this.firstContactor = firstContactor;
	}

	@NotNull
	@Pattern(regexp = "(1\\d{10}){1}", message = "请输入正确格式的手机号码")
	public String getFirstContactorPhoneNumber() {
		return firstContactorPhoneNumber;
	}

	public void setFirstContactorPhoneNumber(String firstContactorPhoneNumber) {
		this.firstContactorPhoneNumber = firstContactorPhoneNumber;
	}

	public String getSecondContactor() {
		return secondContactor;
	}

	public void setSecondContactor(String secondContactor) {
		this.secondContactor = secondContactor;
	}

	@Pattern(regexp = "(1\\d{10})?", message = "请输入正确格式的手机号码")
	public String getSecondContactorPhoneNumber() {
		return secondContactorPhoneNumber;
	}

	public void setSecondContactorPhoneNumber(String secondContactorPhoneNumber) {
		this.secondContactorPhoneNumber = secondContactorPhoneNumber;
	}

	@Min(1L)
	public Integer getEmployeeCount() {
		return employeeCount;
	}

	public void setEmployeeCount(Integer employeeCount) {
		this.employeeCount = employeeCount;
	}

	@Min(0L)
	public Integer getHighTitleEmployeeCount() {
		return highTitleEmployeeCount;
	}

	public void setHighTitleEmployeeCount(Integer highTitleEmployeeCount) {
		this.highTitleEmployeeCount = highTitleEmployeeCount;
	}

	@Min(0L)
	public Integer getMediumTitleEmployeeCount() {
		return mediumTitleEmployeeCount;
	}

	public void setMediumTitleEmployeeCount(Integer mediumTitleEmployeeCount) {
		this.mediumTitleEmployeeCount = mediumTitleEmployeeCount;
	}

	@Min(0L)
	public Integer getBeginnerTitleEmployeeCount() {
		return beginnerTitleEmployeeCount;
	}

	public void setBeginnerTitleEmployeeCount(Integer beginnerTitleEmployeeCount) {
		this.beginnerTitleEmployeeCount = beginnerTitleEmployeeCount;
	}

	public boolean isGovServiceSupplier() {
		return govServiceSupplier;
	}

	public void setGovServiceSupplier(boolean govServiceSupplier) {
		this.govServiceSupplier = govServiceSupplier;
	}



	
	public boolean isAlwaysValid() {
		return alwaysValid;
	}

	public void setAlwaysValid(boolean alwaysValid) {
		this.alwaysValid = alwaysValid;
	}

	@Temporal(TemporalType.DATE)
	public Date getBusnissAllotedTime() {
		return busnissAllotedTime;
	}

	public void setBusnissAllotedTime(Date busnissAllotedTime) {
		this.busnissAllotedTime = busnissAllotedTime;
	}

	public String getBranchesInfo() {
		return branchesInfo;
	}

	public void setBranchesInfo(String branchesInfo) {
		this.branchesInfo = branchesInfo;
	}

	
	@OneToOne(cascade= {CascadeType.PERSIST,CascadeType.MERGE})
	public User getAuditUser() {
		return auditUser;
	}

	public void setAuditUser(User auditUser) {
		this.auditUser = auditUser;
	}

	@Field
	@Boost(0.8F)
	@Length(max = 2000)
	public String getIntro() {
		return intro;
	}

	public void setIntro(String intro) {
		this.intro = intro;
	}
	
	@OneToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE },fetch = FetchType.LAZY)
//	@LazyToOne(value = LazyToOneOption.FALSE)
	@NotNull
	@Size(max = 1)
	@JoinTable(name = "SERVICESUPPLIER_BUSSINESSIMAGE")
	public List<Image> getBusinessLicenseImages() {
		return businessLicenseImages;
	}

	public void setBusinessLicenseImages(List<Image> businessLicenseImages) {
		this.businessLicenseImages = businessLicenseImages;
	}
	
	@OneToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE},fetch = FetchType.LAZY)
//	@Size(min = 1)
	public List<Image> getTaxProveImages() {
		return taxProveImages;
	}

	public void setTaxProveImages(List<Image> taxProveImages) {
		this.taxProveImages = taxProveImages;
	}

	@ElementCollection
	@JoinTable(name = "serviceSupplier_Businesses")
	public List<Business> getBusinesses() {
		return businesses;
	}
	

	public void setBusinesses(List<Business> businesses) {
		this.businesses = businesses;
	}

	@OneToMany( cascade = CascadeType.ALL )
	public List<MainBusiness> getMainBusinesses() {
		return mainBusinesses;
	}
	
	@Transient
	public void addMainBusiness( MainBusiness mainBusiness ) {
		this.mainBusinesses.add( mainBusiness );
	}

	public void setMainBusinesses( List<MainBusiness> mainBusinesses ) {
		this.mainBusinesses = mainBusinesses;
	}

	@OneToMany(cascade = CascadeType.ALL, mappedBy = "serviceSupplier",fetch = FetchType.LAZY)	
	public List<QualificationCert> getCerts() {
		return certs;
	}

	public void setCerts(List<QualificationCert> certs) {
		this.certs = certs;
	}	
	
	@OneToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE},fetch = FetchType.LAZY)
	public List<Attachment> getAttachments() {
		return attachments;
	}

	public void setAttachments(List<Attachment> attachments) {
		this.attachments = attachments;
	}
	

	public BigDecimal getScore() {
		return getCreditScore();
	}
	
	@Transient
	public Integer getIntScore() {
		if (score == null)
			return 0;
		MathContext mc = new MathContext(1); // 3 precision
		return score.round(mc).intValue();
	}

	public void setScore(BigDecimal score) {
//		this.score = score;
	}

	public int getOrderCount() {
		return orderCount;
	}

	public void setOrderCount(int orderCount) {
		this.orderCount = orderCount;
	}

	@Field(analyze = Analyze.NO)
	public boolean isValid() {
		return valid;
	}

	public void setValid(boolean valid) {
		this.valid = valid;
	}


	@Min(0L)
	public BigDecimal getCreditScore() {
		return creditScore;
	}
	
	@Transient
	public CreditLevel getCreditLevel() {
		CreditLevel[] lvls = CreditLevel.values();
		for ( CreditLevel creditLevel : lvls ) {
			boolean passMin = false;
			boolean passMax = false;
			
			if ( creditLevel.getMin() == null ) {
				passMin = true;
			} else {
				int compareToMin = this.getCreditScore().compareTo( new BigDecimal( creditLevel.getMin() ) );
				if ( compareToMin > 0 ) {
					passMin = true;
				}
				if ( compareToMin == 0 && creditLevel.isIncludeMin() ) {
					passMin = true;
				}				
			}
			Integer max = creditLevel.getMax();
			if(max == null) max = 100000;
			int compareToMax = this.getCreditScore().compareTo( new BigDecimal( max ) );
			if ( creditLevel.getMax() == null ) {
				passMax = true;
			} else {
				if ( compareToMax < 0 ) {
					passMax = true;
				}
				if ( compareToMax == 0 && creditLevel.isIncludeMax() ) {
					passMax = true;
				}
			}
			
			
			if ( passMin && passMax ) {
				return creditLevel;
			}
		}
		
		throw new RuntimeException();
	}

	public void setCreditScore( BigDecimal creditScore ) {
		this.creditScore = creditScore;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result + ((address == null) ? 0 : address.hashCode());
		result = prime * result + (alwaysValid ? 1231 : 1237);
		result = prime * result + ((beginnerTitleEmployeeCount == null) ? 0 : beginnerTitleEmployeeCount.hashCode());
		result = prime * result + ((branchesInfo == null) ? 0 : branchesInfo.hashCode());
		result = prime * result + ((busnissAllotedTime == null) ? 0 : busnissAllotedTime.hashCode());
		result = prime * result + ((companyType == null) ? 0 : companyType.hashCode());
		result = prime * result + ((creditCode == null) ? 0 : creditCode.hashCode());
		result = prime * result + ((employeeCount == null) ? 0 : employeeCount.hashCode());
		result = prime * result + ((firstContactor == null) ? 0 : firstContactor.hashCode());
		result = prime * result + ((firstContactorPhoneNumber == null) ? 0 : firstContactorPhoneNumber.hashCode());
		result = prime * result + (govServiceSupplier ? 1231 : 1237);
		result = prime * result + ((highTitleEmployeeCount == null) ? 0 : highTitleEmployeeCount.hashCode());
		result = prime * result + ((intro == null) ? 0 : intro.hashCode());
		result = prime * result + ((legalPerson == null) ? 0 : legalPerson.hashCode());
		result = prime * result + ((legalPersonPhoneNumber == null) ? 0 : legalPersonPhoneNumber.hashCode());
		result = prime * result + ((mediumTitleEmployeeCount == null) ? 0 : mediumTitleEmployeeCount.hashCode());
		result = prime * result + ((region == null) ? 0 : region.hashCode());
		result = prime * result + ((registeredFund == null) ? 0 : registeredFund.hashCode());
		result = prime * result + ((registrationAuthority == null) ? 0 : registrationAuthority.hashCode());
		result = prime * result + ((registrationNo == null) ? 0 : registrationNo.hashCode());
		result = prime * result + ((regtime == null) ? 0 : regtime.hashCode());
		result = prime * result + ((secondContactor == null) ? 0 : secondContactor.hashCode());
		result = prime * result + ((secondContactorPhoneNumber == null) ? 0 : secondContactorPhoneNumber.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		ServiceSupplier other = (ServiceSupplier) obj;
		if (address == null) {
			if (other.address != null)
				return false;
		} else if (!address.equals(other.address))
			return false;
		if (alwaysValid != other.alwaysValid)
			return false;
		if (beginnerTitleEmployeeCount == null) {
			if (other.beginnerTitleEmployeeCount != null)
				return false;
		} else if (!beginnerTitleEmployeeCount.equals(other.beginnerTitleEmployeeCount))
			return false;
		if (branchesInfo == null) {
			if (other.branchesInfo != null)
				return false;
		} else if (!branchesInfo.equals(other.branchesInfo))
			return false;
		if (busnissAllotedTime == null) {
			if (other.busnissAllotedTime != null)
				return false;
		} else if (!busnissAllotedTime.equals(other.busnissAllotedTime))
			return false;
		if (companyType == null) {
			if (other.companyType != null)
				return false;
		} else if (!companyType.equals(other.companyType))
			return false;
		if (creditCode == null) {
			if (other.creditCode != null)
				return false;
		} else if (!creditCode.equals(other.creditCode))
			return false;
		if (employeeCount == null) {
			if (other.employeeCount != null)
				return false;
		} else if (!employeeCount.equals(other.employeeCount))
			return false;
		if (firstContactor == null) {
			if (other.firstContactor != null)
				return false;
		} else if (!firstContactor.equals(other.firstContactor))
			return false;
		if (firstContactorPhoneNumber == null) {
			if (other.firstContactorPhoneNumber != null)
				return false;
		} else if (!firstContactorPhoneNumber.equals(other.firstContactorPhoneNumber))
			return false;
		if (govServiceSupplier != other.govServiceSupplier)
			return false;
		if (highTitleEmployeeCount == null) {
			if (other.highTitleEmployeeCount != null)
				return false;
		} else if (!highTitleEmployeeCount.equals(other.highTitleEmployeeCount))
			return false;
		if (intro == null) {
			if (other.intro != null)
				return false;
		} else if (!intro.equals(other.intro))
			return false;
		if (legalPerson == null) {
			if (other.legalPerson != null)
				return false;
		} else if (!legalPerson.equals(other.legalPerson))
			return false;
		if (legalPersonPhoneNumber == null) {
			if (other.legalPersonPhoneNumber != null)
				return false;
		} else if (!legalPersonPhoneNumber.equals(other.legalPersonPhoneNumber))
			return false;
		if (mediumTitleEmployeeCount == null) {
			if (other.mediumTitleEmployeeCount != null)
				return false;
		} else if (!mediumTitleEmployeeCount.equals(other.mediumTitleEmployeeCount))
			return false;
		if (region == null) {
			if (other.region != null)
				return false;
		} else if (!region.equals(other.region))
			return false;
		if (registeredFund == null) {
			if (other.registeredFund != null)
				return false;
		} else if (!registeredFund.equals(other.registeredFund))
			return false;
		if (registrationAuthority == null) {
			if (other.registrationAuthority != null)
				return false;
		} else if (!registrationAuthority.equals(other.registrationAuthority))
			return false;
		if (registrationNo == null) {
			if (other.registrationNo != null)
				return false;
		} else if (!registrationNo.equals(other.registrationNo))
			return false;
		if (regtime == null) {
			if (other.regtime != null)
				return false;
		} else if (!regtime.equals(other.regtime))
			return false;
		if (secondContactor == null) {
			if (other.secondContactor != null)
				return false;
		} else if (!secondContactor.equals(other.secondContactor))
			return false;
		if (secondContactorPhoneNumber == null) {
			if (other.secondContactorPhoneNumber != null)
				return false;
		} else if (!secondContactorPhoneNumber.equals(other.secondContactorPhoneNumber))
			return false;
		return true;
	}

	public ServiceSupplier() {}

	@Transient
	public String addEmptyBusiness() {
		
		MainBusiness mainBusiness = new MainBusiness();
		String uuid = SystemUUIDUtil.getUUID();
		mainBusiness.setBussinessIndex(uuid);
		AgentService service = new AgentService();
		mainBusiness.setAgentService(service);
		getMainBusinesses().add(mainBusiness);
		return uuid;
	}
	
	@Transient
	public void removeEmptyBusiness(int index) {
		getBusinesses().remove(index);
	}
	
	@Transient
	public void addEmptyCert() {
		QualificationCert cert = new QualificationCert();
		cert.setCertIndex(SystemUUIDUtil.getUUID());
		QualificationTemplate template = new QualificationTemplate();
		template.setTemplateIndex(SystemUUIDUtil.getUUID());
		cert.getQualificationTemplates().add(template);
		getCerts().add(cert);
		cert.setServiceSupplier(this);
	}
	
	@PostLoad
	private void postLoad() {
		this.setHighLightTitle( this.getCnname() );
		StringBuilder sb = new StringBuilder();
		sb.append( this.getCnname() ).append( "," ).append( this.address );
		if ( StringUtils.isNoneEmpty( this.getIntro() ) ) {
			sb.append( "," ).append( this.getIntro() );
		}
		this.setHighLightContent( sb.toString() );
		if ( mainBusinesses.size() > 0 ) {
			for ( MainBusiness mainBusiness : mainBusinesses ) {
				mainBusiness.setBussinessIndex( SystemUUIDUtil.getUUID() );
			}

		}
		
		if(certs.size() > 0) {
			for (QualificationCert cert : certs) {
				cert.setCertIndex(SystemUUIDUtil.getUUID());
//				if(cert.getQualificationTemplates().size() > 0) {
//					for (QualificationTemplate template : cert.getQualificationTemplates()) {
//						template.setTemplateIndex(SystemUUIDUtil.getUUID());
//					}
//				}
			}
		}
	}
	
	@Transient
	public BigDecimal getRandomScore() {
		int random = (int)(Math.random() * 10);
		return random > 0 ? new BigDecimal(40 + random).divide(new BigDecimal(10), 1, RoundingMode.HALF_UP) : new BigDecimal(5);
	}
	
	@Transient
	public int getRandomOrderCount() {
		return (int)(Math.random() * 100);
	}
	
	@Transient
	public Set<QualificationClass> getAllCertClasses() {
		Set<QualificationClass> allClasses = new LinkedHashSet<QualificationClass>();
		for (QualificationCert _cert : this.getCerts()) {
			allClasses.add(_cert.getQualificationClass());
		}
		return allClasses;
	}
	
	@Transient
	public Map<QualificationClass, List<QualificationCert>> getCertGroupByClassMap() {
		Map<QualificationClass, List<QualificationCert>> resultMap = new HashMap<QualificationClass, List<QualificationCert>>();
		for (QualificationCert _cert : this.getCerts()) {
			if (resultMap.get(_cert.getQualificationClass()) == null) {
				resultMap.put(_cert.getQualificationClass(), new ArrayList<QualificationCert>());
			}
			resultMap.get(_cert.getQualificationClass()).add(_cert);
		}
		return resultMap;
	}
	
	@Transient
	public List<QualificationCert> getValidCerts(){
		List<QualificationCert> validCerts = new ArrayList<>();
		for (QualificationCert qualificationCert : getCerts()) {
			if(qualificationCert.getAuditResult() != null && qualificationCert.getAuditResult() && qualificationCert.isValid())
				validCerts.add(qualificationCert);
		}
		return validCerts;
	}
	@Inject
	DeterminedRecordService determinedRecordService;
	
	@Transient
	public boolean isInDeterminedRecord() {
		return determinedRecordService.isExistSupplierInRecord(getId());
	}
	//根据等级获取权重C, C+, B, B+, A, A+分别对应9，14，17，19，20，21
	@Transient
	public Integer getWeight() {
		return getWeightLevelMap().get(getCreditLevel());
	}
	@Transient
	public Map<CreditLevel,Integer> getWeightLevelMap() {
		Map<CreditLevel,Integer> weightLevelMap = new HashMap<CreditLevel,Integer>();
		for (int i = 0; i < RandomChooseService.LEVEL_ARRAY.length; i++) {
			weightLevelMap.put(RandomChooseService.LEVEL_ARRAY[i], RandomChooseService.WEIGHT_ARRAY[i]);
		}
		return weightLevelMap;
	}
	@Transient
	public String getLevelLabel() {
		Map<CreditLevel,String> levelLabelMap = new HashMap<CreditLevel,String>();
		for (int i = 0; i < RandomChooseService.LEVEL_ARRAY.length; i++) {
			levelLabelMap.put(RandomChooseService.LEVEL_ARRAY[i], RandomChooseService.LEVEL_LABEL[i]);
		}
		
		return levelLabelMap.get(getCreditLevel()) == null ? "D" : levelLabelMap.get(getCreditLevel());
	}
	
}
